Skip to content

Speed up preloads with duplicate code points #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2019

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented May 21, 2019

The original logic wouldn't recognize duplicate characters
in the given set to preload and therefore it'd read the whole
font file looking for a character it already found. A set
deduplicates the given characters at a small memory cost.

This drops the font preload for PyPortal from 22 seconds
to just over 2 seconds. (The preload string has duplicate
exclamation points.)

The original logic wouldn't recognize duplicate characters
in the given set to preload and therefore it'd read the whole
font file looking for a character it already found. A set
deduplicates the given characters at a small memory cost.
@tannewt tannewt requested a review from ladyada May 21, 2019 22:58
@ladyada
Copy link
Member

ladyada commented May 22, 2019

omgggg im so happy

@ladyada ladyada merged commit 1c0d724 into adafruit:master May 22, 2019
@makermelissa
Copy link
Collaborator

I just tried this out on my Nametag PyBadge code and it loaded SO much faster. Thanks!

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request May 23, 2019
Updating https://github.com/adafruit/Adafruit_CircuitPython_LPS35HW to 1.1.2 from 1.1.0:
  > pylint fix
  > text fixes, product ID update

Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 3.0.2 from 3.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#32 from seantibor/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_STMPE610 to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_STMPE610#8 from jpecor/patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bitmap_Font to 1.0.3 from 1.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_Bitmap_Font#11 from tannewt/improve_preload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants